//Copyright (c) Microsoft Corporation.  All rights reserved.

using System;
using System.Collections.Generic;
using System.Text;

namespace Eas.WebCrawler.PlugIns.RequestComparers {
    /// <summary>Copmares the priority of two requests and gives higher priority to the one whose uri would be sorted earlier alphabetically.</summary>
    /// <remarks>Using this comparer will mean that requests get processed in alphabetic (dictionary) order.</remarks>
    public class AlphabeticComparer : BaseComparer {

        /// <summary>Compares two <see cref="Uri"/>s to see which one comes first in an alphabetic sorting of the request's Uris.</summary>
        /// <param name="leftRequest">The left <see cref="Eas.WebCrawler.Interfaces.Request"/> to compare.</param>
        /// <param name="rightRequest">The right <see cref="Eas.WebCrawler.Interfaces.Request"/> to compare.</param>
        /// <returns>A <see cref="CompareResult"/> declaring if the left or right <see cref="Eas.WebCrawler.Interfaces.Request"/> is higher priority.</returns>
        public override CompareResult CompareUris(Eas.WebCrawler.Interfaces.Request leftRequest, Eas.WebCrawler.Interfaces.Request rightRequest) {
            return (CompareResult)leftRequest.Uri.ToString().CompareTo(rightRequest.Uri.ToString());
        }
    }
}
